package com.atguigu.tingshu.album.api;


import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.mapper.BaseAttributeMapper;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {

	@Autowired
	private BaseCategoryService baseCategoryService;




	/**
	 * 查询所有分类（1、2、3级分类）
	 * @return
	 */
	@GetMapping("/category/getBaseCategoryList")
	public Result<List<JSONObject>> getBaseCategoryList (){
		List<JSONObject> jsonObjectList = baseCategoryService.getBaseCategoryList();
		return Result.ok(jsonObjectList);
	}

	/**
	 * 根据一级分类Id获取分类属性（标签）列表
	 * @param category1Id
	 * @return
	 */
	@GetMapping("/category/findAttribute/{category1Id}")
	public Result<List<BaseAttribute>> findAttribute(@PathVariable Long category1Id){
		List<BaseAttribute> baseAttributeList = baseCategoryService.findAttribute(category1Id);
		return Result.ok(baseAttributeList);
	}
}

